package cn.ecpay.unionpay.settle.notify;

import cn.ecpay.unionpay.settle.Common.RespCode;
import cn.ecpay.unionpay.settle.util.CommonBase;
import cn.ecpay.unionpay.settle.util.FsasService;
import cn.ecpay.unionpay.settle.util.LogUtil;
import org.springframework.stereotype.Component;

import javax.servlet.ServletException;
import java.io.IOException;
import java.util.Map;

/**
 * 单笔查询通知
 * Created by zhaoyanzeng on 2018/11/26.
 */
@Component
public class SingleQueryNotify {

    public void singleQuery(Map<String, String> reqParam)
            throws ServletException, IOException {
        LogUtil.writeLog("单笔查询异步通知开始");
        // 获取银联通知服务器发送的后台通知参数
        LogUtil.printRequestLog(reqParam);
        if (!FsasService.validate(reqParam, CommonBase.encoding)) {
            LogUtil.writeLog("验证签名结果[失败].");
        } else {
            LogUtil.writeLog("验证签名结果[成功].");
            String respCode = reqParam.get("respCode");
            if (RespCode.RESP_SUCCESS.equals(respCode)) {
                //TODO 成功
            } else {
                //TODO 失败
            }
            LogUtil.writeLog("respCode=" + respCode);
        }
        LogUtil.writeLog("单笔查询异步通知结束");
    }
}
